#pragma once
/*
 *  OutputControl.h
 *  NXTFace
 *
 *  Created by David Giovannini on 8/23/06.
 *  Copyright 2006 Software by Jove. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#import <Cocoa/Cocoa.h>
#import "NxtDevice.h"

namespace SBJ
{
namespace NXT
{
class Output;
}
}

enum EStopWith
{
	stop_brake = 'EBrk',
	stop_coast = 'ECst'
};

enum ERegulation
{
	reg_idle = 'ERId',
	reg_speed = 'ESpd',
	reg_sync = 'ESyn',
};

enum EMotorState
{
	motorState_idle = 'ESId',
	motorState_rampUp = 'ERpU',
	motorState_running = 'ERun',
	motorState_rampDown = 'ERpD'
};

enum EMotorUnit
{
	motorUnit_degrees = 'EMUD'
};

@interface NxtOutput : NSObject
{	
	NxtDevice* m_device;
	SBJ::NXT::Output* m_output;
}

-(id) initOutputOf: (NxtDevice*)theDevice on: (unsigned char)port;

// KVC Read-Only Attributes
- (unsigned char) Port;
- (NSString*) Name;
- (BOOL) InMotion;
- (long) Tacho;
- (long) BlockTacho;
- (long) RotateTacho;

// KVC Read Attributes
- (char) Power;
- (BOOL) On;
- (BOOL) UsesBrake;
- (BOOL) Regulated;
- (char) TurnRatio;
- (unsigned long) TachoLimit;

// KVC Write Attributes
- (void) setPower:		(char)value;
- (void) setOn:			(BOOL)value;
- (void) setUsesBrake:	(BOOL)value;
- (void) setRegulated:	(BOOL)value;
- (void) setTurnRatio:	(char)value;
- (void) setTachoLimit:	(unsigned long)value;
	
- (void) start: (char)power;
- (void) stopWith: (EStopWith)what;
- (void) start: (double)speed For: (double)duration Using: (EMotorUnit)unit Then: (EStopWith)stopMode;
- (void) reset: (BOOL)relative;

@end
